/**
 * User: Farside
 * Date: Apr 29, 2009
 * To change this template use File | Settings | File Templates.
 */

public class QueryService {
  static boolean transactional = false

  def futureEvents(max) {
    def events = Event.createCriteria()
    return events.list {
      gt("endDate", new Date((new Date()).day))
      maxResults(max)
    }
  }

  def myEvents(volunteer, max) {
    def events = Event.createCriteria()
    return events.list {
      eq("owner", volunteer)
      maxResults(max)
    }
  }

  def eventCount() {
    def events = Event.createCriteria()
    return events.get {
      projections {
        rowCount()
      }
    }
  }
}